package com.conversationboard.model;

import java.util.UUID;
import java.util.regex.Pattern;

public class Substitution {

    private String id;
    private String loginId;
    private String ipAddress;
    private String regularExpression;
    private transient Pattern pattern = null;
    private String substitution;


    public Substitution() {
        this.id = UUID.randomUUID().toString();
    }


    public String getId() {
        return id;
    }


    public void setId(String id) {
        this.id = id;
    }


    public String getIpAddress() {
        return ipAddress;
    }


    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }


    public String getLoginId() {
        return loginId;
    }


    public void setLoginId(String loginId) {
        this.loginId = loginId;
    }


    public String getRegularExpression() {
        return regularExpression;
    }


    public void setRegularExpression(String regularExpression) {
        this.regularExpression = regularExpression;
    }


    public Pattern getPattern() {

        if (this.pattern == null) {
            this.pattern = Pattern.compile(this.getRegularExpression(), (Pattern.CASE_INSENSITIVE | Pattern.DOTALL));
        }

        return this.pattern;

    }


    public String getSubstitution() {
        return substitution;
    }


    public void setSubstitution(String substitution) {
        this.substitution = substitution;
    }

}
